package com.njuse.jvmfinal.Instruction;

import java.nio.ByteBuffer;

import com.njuse.jvmfinal.runtimestructure.Jarray;
import com.njuse.jvmfinal.runtimestructure.Jframe;

public class AALOAD extends Instruction {
	
	public  void readindex(ByteBuffer reader) {
		//pass
	}
	
	public  void execute(Jframe frame) {
		int top=frame.getStacktop();
		Object[] stack=frame.getManagestack();
		int index=(int) stack[top-1];
		Jarray array=(Jarray) stack[top-2];
		top=top-2;
		Object value=array.getJarray()[index];
		stack[top]=value;
		top++;
		frame.setManagestack(stack);
		frame.setStacktop(top);
	}
}
